import concurrent
import json

import aiohttp
from curl_cffi import requests
import asyncio


# page = 1
# url = f'https://push2.eastmoney.com/api/qt/clist/get?np=1&fltt=1&invt=2&fs=m%3A0%2Bt%3A6%2Bf%3A!2%2Cm%3A0%2Bt%3A80%2Bf%3A!2%2Cm%3A1%2Bt%3A2%2Bf%3A!2%2Cm%3A1%2Bt%3A23%2Bf%3A!2%2Cm%3A0%2Bt%3A81%2Bs%3A262144%2Bf%3A!2&fields=f12%2Cf13%2Cf14%2Cf1%2Cf2%2Cf4%2Cf3%2Cf152%2Cf5%2Cf6%2Cf7%2Cf15%2Cf18%2Cf16%2Cf17%2Cf10%2Cf8%2Cf9%2Cf23&fid=f3&pn={page}&pz=20&po=1&dect=1&ut=fa5fd1943c7b386f172d6893dbfba10b&wbp2u=%7C0%7C0%7C0%7Cweb&_=1762236267381'
#
headers = {
'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36',
'referer':'https://quote.eastmoney.com/center/gridlist.html',
    'cookie':'fullscreengg=1; fullscreengg2=1; qgqp_b_id=7758bca73f98c63a7aa46d815a7ae808; st_nvi=-JvaU4Xt0kypRZFSW85NB78e7; st_si=28660383069426; st_asi=delete; nid=0984e82cd59c5d27f036cc0760a99f05; nid_create_time=1762236258851; gvi=FlRvzZGwzKHP0mDkYewIna30f; gvi_create_time=1762236258851; st_sn=2; st_psi=20251104142229942-113200301321-5212823530; st_pvi=65861793892099; st_sp=2025-11-04%2014%3A04%3A18; st_inirUrl='


}
# response = requests.get(url,headers=headers)
#
# resp = response.json()
#
# print(resp["data"]['diff'][0]['f14'])

# print(type(resp),resp['data'])





async def fetch(session,url):
    async with session.get(url) as response:
        data = await response.json()

        for item in data['data']['diff']:
            print(item['f14'])



async def main():
    async with aiohttp.ClientSession(headers=headers) as session:
        urls = [f'https://push2.eastmoney.com/api/qt/clist/get?np=1&fltt=1&invt=2&fs=m%3A0%2Bt%3A6%2Bf%3A!2%2Cm%3A0%2Bt%3A80%2Bf%3A!2%2Cm%3A1%2Bt%3A2%2Bf%3A!2%2Cm%3A1%2Bt%3A23%2Bf%3A!2%2Cm%3A0%2Bt%3A81%2Bs%3A262144%2Bf%3A!2&fields=f12%2Cf13%2Cf14%2Cf1%2Cf2%2Cf4%2Cf3%2Cf152%2Cf5%2Cf6%2Cf7%2Cf15%2Cf18%2Cf16%2Cf17%2Cf10%2Cf8%2Cf9%2Cf23&fid=f3&pn={page}&pz=20&po=1&dect=1&ut=fa5fd1943c7b386f172d6893dbfba10b&wbp2u=%7C0%7C0%7C0%7Cweb&_=1762236267381'for page in range(1,5)]
        tasks = [fetch(session,url)for url in urls]
        datas = await asyncio.gather(*tasks)
        # print(datas)
asyncio.run(main())

















# urls = [f'https://push2.eastmoney.com/api/qt/clist/get?np=1&fltt=1&invt=2&fs=m%3A0%2Bt%3A6%2Bf%3A!2%2Cm%3A0%2Bt%3A80%2Bf%3A!2%2Cm%3A1%2Bt%3A2%2Bf%3A!2%2Cm%3A1%2Bt%3A23%2Bf%3A!2%2Cm%3A0%2Bt%3A81%2Bs%3A262144%2Bf%3A!2&fields=f12%2Cf13%2Cf14%2Cf1%2Cf2%2Cf4%2Cf3%2Cf152%2Cf5%2Cf6%2Cf7%2Cf15%2Cf18%2Cf16%2Cf17%2Cf10%2Cf8%2Cf9%2Cf23&fid=f3&pn={page}&pz=20&po=1&dect=1&ut=fa5fd1943c7b386f172d6893dbfba10b&wbp2u=%7C0%7C0%7C0%7Cweb&_=1762236267381'for page in range(1,5)]
#
# headers = {
# 'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36',
# 'referer':'https://quote.eastmoney.com/center/gridlist.html',
#     'cookie':'fullscreengg=1; fullscreengg2=1; qgqp_b_id=7758bca73f98c63a7aa46d815a7ae808; st_nvi=-JvaU4Xt0kypRZFSW85NB78e7; st_si=28660383069426; st_asi=delete; nid=0984e82cd59c5d27f036cc0760a99f05; nid_create_time=1762236258851; gvi=FlRvzZGwzKHP0mDkYewIna30f; gvi_create_time=1762236258851; st_sn=2; st_psi=20251104142229942-113200301321-5212823530; st_pvi=65861793892099; st_sp=2025-11-04%2014%3A04%3A18; st_inirUrl='
#
#
# }
# def fetch(url):
#     res = requests.get(url,headers = headers)
#     items = res.json()["data"]['diff']
#     for item in items:
#
#         print(item['f14'])
#
#
# with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:
#     for url in urls:
#         executor.submit(fetch,url)




